package com.example.shutdown_v1.repository;

import com.example.shutdown_v1.entity.DailyInspectionRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

@Repository
public interface DailyInspectionRecordRepository extends JpaRepository<DailyInspectionRecord, Long> {
    
    /**
     * 查询指定店铺在指定时间范围内的巡检记录
     */
    List<DailyInspectionRecord> findByShopIdAndInspectionTimeBetween(
            Long shopId, LocalDateTime startTime, LocalDateTime endTime);
    
    /**
     * 查询指定店铺的最新巡检记录
     */
    Optional<DailyInspectionRecord> findFirstByShopIdOrderByInspectionTimeDesc(Long shopId);
    
    /**
     * 查询所有不合规的巡检记录
     */
    List<DailyInspectionRecord> findByIsCompliantOrderByInspectionTimeDesc(Boolean isCompliant);
    
    /**
     * 查询指定店铺不合规的巡检记录
     */
    List<DailyInspectionRecord> findByShopIdAndIsCompliantOrderByInspectionTimeDesc(
            Long shopId, Boolean isCompliant);
}

